﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FisheryPlatform.SiteConfig.FileStore;

namespace FisheryPlatform.Bussiness.FileStore
{
    public class ContactInfoImageUploadProvider : FileUploadProviderBase
    {
        public static string defaultExtensionName = "product.jpg";
        public ContactInfoImageUploadProvider(UploadFileEntity entity)
        {
            base.Init(entity, false, FileUploadConstants.ServiceType_ContactInfo, FileUploadConstants.MimeItemKey_Image);
        }

        /// <summary>
        /// 文件内容
        /// </summary>
        public static string GetFileContent(DateTime uploadDate, string uploadFileId)
        {
            UploadFileEntity entity = new UploadFileEntity(uploadFileId, defaultExtensionName, new byte[0]);
            entity.UploadDate = uploadDate;

            ContactInfoImageUploadProvider provider = new ContactInfoImageUploadProvider(entity);
            return provider.Read(provider.FileServer.RootPath + entity.PublishUrlPath.Replace("/", "\\"));
        }

        /// <summary>
        /// 文件内容
        /// </summary>
        public static byte[] GetFileContent(string publishUrlPath)
        {
            UploadFileEntity entity = new UploadFileEntity("0", defaultExtensionName, new byte[0]);
            ContactInfoImageUploadProvider provider = new ContactInfoImageUploadProvider(entity);
            return provider.ReadBytes(provider.FileServer.RootPath + publishUrlPath.Replace("/", "\\"));
        }
    }
}
